/**
 * 模拟登录接口
 * @param {*}
 * @returns
 */
export const login = (obj: any) => {
  const returns = {
    code: 401,
    data: {},
    msg: '账号或密码错误'
  }
  if (obj && obj.username == 'admin' && obj.password == '123456') {
    returns.data = {
      token: 'abcdefg'
    }
    returns.code = 200
    returns.msg = '登录成功'
  }
  if (obj && obj.username == '6464' && obj.password == '123456') {
    returns.data = {
      token: 'qwert'
    }
    returns.code = 200
    returns.msg = '登录成功'
  }
  return new Promise((resolve) => resolve(returns))
}

/**
 * 获取用户信息
 * @param {*}
 * @returns
 */

export const getUserInfo = (token: string) => {
  const returns = {
    code: 200,
    data: {},
    msg: ''
  }
  if (token == 'abcdefg') {
    const user = {
      userName: '管理员',
      id: '6464'
    }
    returns.data = user
  }
  if (token == 'qwert') {
    const user = {
      userName: '员工',
      id: '7878'
    }
    returns.data = user
  }
  return new Promise((resolve) => resolve(returns))
}
